package client.comm.baoding.adapter

import android.content.Context
import androidx.recyclerview.widget.DiffUtil
import client.comm.baoding.R
import client.comm.baoding.api.bean.Zcjl
import client.comm.baoding.databinding.LayoutFejjlitemBinding
import client.comm.baoding.databinding.LayoutGpjlitemBinding
import client.comm.commlib.base.BasePagingAdapter
import client.comm.commlib.base.PagingViewHoder

import com.bumptech.glide.RequestManager
import com.google.gson.Gson

class FejlPagingAdapter(val context: Context, val manager: RequestManager) :
    BasePagingAdapter<Zcjl.Record>(object : DiffUtil.ItemCallback<Zcjl.Record>() {
        val g = Gson()

        override fun areItemsTheSame(
            oldItem: Zcjl.Record,
            newItem: Zcjl.Record
        ): Boolean {
            return true
        }

        override fun areContentsTheSame(
            oldItem: Zcjl.Record,
            newItem: Zcjl.Record
        ): Boolean {
            return g.toJson(oldItem).equals(g.toJson(newItem))
        }
    }) {

    override fun bindItem(holder: PagingViewHoder, t: Any) {
        val binding = holder.binding as LayoutFejjlitemBinding
        val bean = t as Zcjl.Record
        binding.bean = bean
        binding.gs = if(bean.r_state == 1) "+${bean.num}"  else "-${bean.num}"
    }

    override fun getItemLayout(): Int {
        return R.layout.layout_fejjlitem
    }
}